<template>
    <div>
        <h2>房号列表</h2>
        <div>
            <span> 房号名称</span>
            <input type="text" v-model="housenook.HouseNumber">
            <span> 时间</span>
            <input type="date" v-model="housenook.CreateTime">
            <input type="button" class="btn btn-success" value="查询" @click="ok">
        </div>
        <table class="table  table-bordered">
            <tbody>
                <tr class="bg-primary">
                    <td>房型名称</td>
                    <td>房号名称</td>
                    <td>排序</td>
                    <td>时间</td>
                    <td>备注</td>
                    <td>状态</td>
                    <td>操作</td>
                </tr>



                <tr v-for="item in list" :key="item.Id">
                    <td>{{item.HouseNoName}}</td>
                    <td>{{item.HouseNumber}}</td>
                    <td>{{item.OrderNum}}</td>
                    <td>{{item.CreateTime}}</td>
                    <td>{{item.BeiZhu}}</td>
                    <td>{{item.State==1?"上架" :"下架"}}</td>
                    <td>
                        <input type="button" class="btn btn-info" value="编辑" @click="HouseUpd(item.Id)">
                    </td>
                </tr>
            </tbody>
        </table>
      
    </div>
</template>

<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import axios from 'axios';

const route = useRoute();
const router = useRouter();


let list:any = ref([])
//显示房号
let housenook = reactive({
    HouseNumber: '',
    CreateTime: '',
})

onMounted(()=>{
    ok();
})


//显示房号
const ok=()=>{

axios({

url:'https://localhost:7259/api/HouseNo/HouseNoList',
method:'get',
params:housenook,
})

.then((res)=>{
    console.log(res);
   list.value=res.data;
})


.catch((ree)=>{
    console.log(ree);
})



}


//编辑
const HouseUpd=(Id:any)=>{

router.push({
path:'/HouseNoUpd',
query:{
Id:Id
}

})



}
</script>

<style scoped></style>